x86/pvh: check permissions when adding MMIO regions
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 23 Jan 2015 14:15:30 +0000 (15:15 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Jan 2015 14:15:30 +0000 (15:15 +0100)
Check that MMIO regions added to PVH Dom0 are allowed. Previously a PVH Dom0
would have access to the full MMIO range.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/domain_build.c

index 01cfa58746af2304645d11d5ce5a199a625b754f..2f9aaf95e60d7f46918289ac29894beac65b16f5 100644 (file)
@@ -320,11 +320,24 @@ static __init void pvh_add_mem_mapping(struct domain *d, unsigned long gfn,
 {
     unsigned long i;
     p2m_access_t a;
+    mfn_t omfn;
+    p2m_type_t t;
     int rc;
 
-    a = p2m_get_hostp2m(d)->default_access;
     for ( i = 0; i < nr_mfns; i++ )
     {
+        if ( !iomem_access_permitted(d, mfn + i, mfn + i) )
+        {
+            omfn = get_gfn_query_unlocked(d, gfn + i, &t);
+            guest_physmap_remove_page(d, gfn + i, mfn_x(omfn), PAGE_ORDER_4K);
+            continue;
+        }
+
+        if ( rangeset_contains_singleton(mmio_ro_ranges, mfn + i) )
+            a = p2m_access_rx;
+        else
+            a = p2m_access_rwx;
+
         if ( (rc = set_mmio_p2m_entry(d, gfn + i, _mfn(mfn + i), a)) )
             panic("pvh_add_mem_mapping: gfn:%lx mfn:%lx i:%ld rc:%d\n",
                   gfn, mfn, i, rc);